#include<ros/ros.h>
#include<iostream>
#include<pcl/io/pcd_io.h>
#include<pcl/point_cloud.h>
#include<pcl/point_types.h>
#include<sensor_msgs/PointCloud2.h>
#include<pcl/filters/voxel_grid.h>
#include<pcl_conversions/pcl_conversions.h>

using namespace std;
using namespace ros;
using namespace pcl;
Publisher pub;
int main(int argc,char** argv)
{
  init(argc,argv,"my_pcl");
  NodeHandle nh;
  pub=nh.advertise<sensor_msgs::PointCloud2>("output",1);
  PointCloud<PointXYZRGB>:: Ptr cloud (new PointCloud<PointXYZRGB>);
  sensor_msgs::PointCloud2 output;
  io::loadPCDFile("/home/lfz_5/文档/robot/Projects/rviz_pcl/src/my_pcl/src/1.pcd",*cloud);
  VoxelGrid<PointXYZRGB> sor;
  sor.setInputCloud(cloud);
  sor.setLeafSize(0.006f, 0.006f, 0.006f);
  sor.filter(*cloud);
  toROSMsg(*cloud,output);
  output.header.frame_id="odom";
  Rate loop_rate(1);
  while(ok())
  {
    pub.publish(output);
    spinOnce();
    loop_rate.sleep();    
  }
  return 0;
}